package com.example.floatingpopulation.controller;

import com.example.floatingpopulation.common.Result;
import com.example.floatingpopulation.controller.request.FloatingPopulationPageRequest;
import com.example.floatingpopulation.controller.request.TemporaryResidencePermitPageRequest;
import com.example.floatingpopulation.entity.TemporaryResidencePermit;
import com.example.floatingpopulation.service.TemporaryResidencePermitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/temporaryResidencePermit")
public class TemporaryResidencePermitController {
    @Autowired
    TemporaryResidencePermitService temporaryResidencePermitService;


    @PostMapping("/save")
    public Result<String> save(@RequestBody TemporaryResidencePermit obj) {
        temporaryResidencePermitService.save(obj);
        return Result.success();
    }

    @PutMapping("/update")
    public Result<String> update(@RequestBody TemporaryResidencePermit obj) {
        temporaryResidencePermitService.update(obj);
        return Result.success();
    }


    @DeleteMapping("/delete/{id}")
    public Result<String> delete(@PathVariable Integer id){
        temporaryResidencePermitService.deleteById(id);
        return Result.success();
    }


    @GetMapping("/list")
    public Result<String> list(){
        List<TemporaryResidencePermit> list = temporaryResidencePermitService.list();
        return Result.success(list);
    }


    @GetMapping("/page")
    public Result<String> page(TemporaryResidencePermitPageRequest pageRequest){
        return Result.success(temporaryResidencePermitService.page(pageRequest));
    }

}
